<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="btns">
    <button data-num="1">按钮</button>
    <button data-num="1">按钮</button>
    <button data-num="1">按钮</button>
</div>

<script>
    var i=2
    let div=document.querySelector('.btns')
    div.onclick=function (evt) {
        let num=evt.target.getAttribute('data-num')
        if (num) {
            confirm('我是按钮'+num+",是否生成新的按钮")
            let newBtn=document.createElement('button')
            newBtn.setAttribute('data-num',i)
            newBtn.appendChild(document.createTextNode("按钮"+i))
            evt.target.parentNode.appendChild(newBtn)
            i++
        }
    }
</script>
</body>
</html>
